package cz.muni.fi.pa165.sportclubmanager.service;

import cz.muni.fi.pa165.sportclubmanager.dto.PlayerDTO;
import cz.muni.fi.pa165.sportclubmanager.dto.RosterDTO;
import cz.muni.fi.pa165.sportclubmanager.dto.TeamDTO;
import java.util.List;

/**
 * Provides basic operations with team roster.
 * There are following restrictions which hold after execution of any method:
 * <ol>
 * <li>Each team roster consists of distinct players.</li>
 * <li>Each team roster consists of either players from age category of the
 * team, or players from age category right below the team's one.
 * More exactly player's age is between lower category ageFrom and team
 * category ageTo, both inclusive.</li>
 * <li>No player can be on more than one roster of teams within the same age
 * category.</li>
 * <li>All players on one roster have different numbers assigned and this number
 * is from interval &lt;1,99&gt;.</li>
 * </ol>
 *
 * @author Michal Prokeš, 72758
 */
public interface RosterService {

    /**
     * Adds Player to team roster and assigns given jersey number to
     * him.
     *
     * @param team   not null team with id set
     * @param player not null player with id set
     * @param number unique number (1..99) in team roster
     * @throws RosterException when player is already on some roster (including
     *                         given team) with same age category as given team
     *                         or when player doesn't match age category criteria
     *                         or when number is not unique within the roster
     */
    public void addPlayerToRoster(TeamDTO team, PlayerDTO player, int number);

    /**
     * Removes Player from Team roster. If no such relation exists, do nothing.
     *
     * @param roster not null DTO for PlayerOnRoster with id set
     */
    public void removePlayerFromRoster(RosterDTO roster);

    /**
     * Changes number of player on team roster. Only id and number field matter,
     * others are ignored.
     *
     * @param roster not null DTO for PlayerOnRoster with id set and new
     *               roster-unique number
     * @throws RosterException when number is not unique within the roster
     */
    public void changeNumber(RosterDTO roster);

    /**
     * List of players on Roster filtered by Team
     *
     * @param team not null team with id set
     * @return List of playerOnRoster relations filtered by team
     */
    public List<RosterDTO> getPlayersOnRoster(TeamDTO team);
    
    /**
     * List of players avalilable for adding to team sorted by last name and first name in ascending order.
     *
     * @param team not null team with id set
     * @return List of players avalilable for adding to team sorted by last name and first name in ascending order.
     */
    public List<PlayerDTO> getPlayersAvailableForRoster(TeamDTO team);

    /**
     * List of teams filtered by player
     *
     * @param player not null player with id set
     * @return List of teams with given player
     */
    public List<TeamDTO> getTeamsWithPlayer(PlayerDTO player);
}
